//
//  TWVideoCollectionOfAuthorWithCoverCell.swift
//  EyepetizerImitative
//
//  Created by 田伟 on 2017/3/30.
//  Copyright © 2017年 个人. All rights reserved.
//

import UIKit

class TWVideoCollectionOfAuthorWithCoverCell: UITableViewCell {

    @IBOutlet weak var bgImageView: UIImageView!
    @IBOutlet weak var detailCollectionView: TWDetailCollectionView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var detailLabel: UILabel!
    @IBOutlet weak var attentionButton: UIButton!
    
    // 点击关注
    @IBAction func attentionButtonClick() {
    }
    
    // MARK:- 自定义属性
    var VideoCollectionOfAuthorWithCoverModel : TWVideoCollectionOfAuthorWithCoverModel?{
        didSet {
            guard let VideoCollectionOfAuthorWithCoverModel = VideoCollectionOfAuthorWithCoverModel else {
                return
            }
            
            let urlString = VideoCollectionOfAuthorWithCoverModel.header?.cover
            let urlStringIcon = VideoCollectionOfAuthorWithCoverModel.header?.icon
            guard let urlStr = urlString else {
                return
            }
            guard let urlStringIcon1 = urlStringIcon else {
                return
            }
            // 设置大图控件
            bgImageView.sd_setImage(with: URL(string: urlStr))
            iconImageView.sd_setImage(with: URL(string: urlStringIcon1))
            titleLabel.text = VideoCollectionOfAuthorWithCoverModel.header?.title
            detailLabel.text = VideoCollectionOfAuthorWithCoverModel.header?.tw_description
            // 设置detailCollectionView的内容
            detailCollectionView.videosArray = VideoCollectionOfAuthorWithCoverModel.itemList_tw
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        // 添加边框
        attentionButton.layer.masksToBounds = true
        attentionButton.layer.cornerRadius = 4
        attentionButton.layer.borderWidth = 1
        attentionButton.layer.borderColor = UIColor.white.cgColor
        let tap = UITapGestureRecognizer(target: self, action: #selector(bigImageViewDidTap(tap:)))
        bgImageView.addGestureRecognizer(tap)
    }
    
    @objc fileprivate func bigImageViewDidTap(tap : UITapGestureRecognizer){
        print((VideoCollectionOfAuthorWithCoverModel?.header?.actionUrl)! as String)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
}
